/**
 * 订单处理-统一入口
 */

const actionHandle = (event) => {
    console.log(event)
    return new Promise((resolve, reject) => {

        switch (event.type) {
            case 'detail':
                uni.navigateTo({
                    url: `/pages/order/detail/detail?orderId=${event.data.OrderId}`
                });
                break;
            case 'sign':
                uni.navigateTo({
                    url: `/pages/order/contract/sign?orderId=${event.data.OrderId}`
                });
                break;
            case 'pay':
                uni.navigateTo({
                    url: `/pages/order/pay/pay?orderId=${event.data.OrderId}`
                });
                break;
            case 'plan':
                uni.navigateTo({
                    url: `/pages/order/plan/plan?orderId=${event.data.OrderId}`
                });
                break;
            case 'cancel':
                uni.navigateTo({
                    url: `/pages/order/cancel/cancel?orderId=${event.data.OrderId}`
                });
                break;
            case 'refund':
                uni.navigateTo({
                    url: `/pages/order/refund/refund?orderId=${event.data.OrderId}`
                });
                break;
            case 'delete':
                that.$dialog.confirm('提示', '确定要删除定购记录？').then(res => {
                    if (res) {
                        this.$dialog.loading('正在删除');
                        this.$request('order', 'delete', {
                            OrderId: event.data.OrderId
                        }).then(res => {
                            uni.$emit('order-update', {
                                type: 'delete',
                                orderId: event.data.OrderId
                            })
                            this.$dialog.hide();
                        
                        }).catch(err => {
                            this.$dialog.msg(err.msg);
                        })
                    }
                });
                break;
            case 'urge':
                this.$request('order', 'urge', {
                    OrderId: event.data.OrderId
                }).then(res => {
                    this.$dialog.msg('已通知卖家尽快给您发货');
                })
                break;
            case 'receive':
                uni.navigateTo({
                    url: `/pages/order/recv/recv?orderId=${event.data.OrderId}`
                });
                break;
            case 'feedback':
                uni.navigateTo({
                    url: `/pages/order/feedback/feedback?orderId=${event.data.OrderId}`
                });
                break;
            case 'phone':
                break;

            case 'confirmrefund':
                break;
            case 'refuserefund':
                break;
            case 'confirmpay':
                break;
            case 'refusepay':
                break;
            case 'confirmplan':
                break;
            case 'refuseplan':
                break;
            case 'send':
                break;

            default:
                break;
        }
    })
}

export default {
    actionHandle,
}
